home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / bpwmru.zip / OMRULIST.INT < prev    next >
Text File  |  1993-06-04  |  6KB  |  127 lines

  1. { *************************************************************************** }
  2. {                  V I S U A L  I M P L E M E N T A T I O N                   }
  3. {                                  Part One                                   }
  4. {                        Most Recently Used File List                         }
  5. {                   Pascal Version (C)1993 Bobby R. Wallen                    }
  6. { *************************************************************************** }
  7. unit OMRUList;
  8. interface
  9. uses WinTypes, Objects;
  10.  
  11. const
  12.      { Allow for up to nine (9) Remembered Files }
  13.      CM_File1 = 5000;
  14.      CM_File2 = 5001;
  15.      CM_File3 = 5002;
  16.      CM_File4 = 5003;
  17.      CM_File5 = 5004;
  18.      CM_File6 = 5005;
  19.      CM_File7 = 5006;
  20.      CM_File8 = 5007;
  21.      CM_File9 = 5008;
  22.  
  23.      { Initialized ( Static ) variable/Constants }
  24.      nMaxItems : Integer = 5;        { Default Number if Items in List }
  25.      hMDIWnd   : HWND = 0;           { MDI Client Window Handle }
  26.      DefIni    : PChar = 'WIN.INI';
  27.      DefKey    : PChar = 'files';
  28.      cFile     : Integer = 0;    { Number of remembered files }
  29.      cFileList : Integer = 0;    { Number of files in FileMenu List }
  30.  
  31. type
  32.     TItemFmt = record
  33.       ID : Integer;
  34.       Name : PChar;
  35.     end;
  36.  
  37.     PMRUItem = ^TMRUItem;
  38.     TMRUItem = object( TObject )
  39.       ItemName : PChar;
  40.       constructor Init( AName: PChar );
  41.       destructor  Done; virtual;
  42.     end;
  43.  
  44.     PMRUList = ^TMRUList;
  45.     TMRUList = object( TCollection )
  46.       constructor Init(CWnd: HWND; ALimit, ADelta: Integer );
  47.       destructor  Done; virtual;
  48.       procedure AddMRUItem( AWnd: HWND; AName: PChar ); virtual;
  49.       procedure DeleteMRUItem( AWnd: HWND; AName: PChar ); virtual;
  50.       function  GetMRUItem( AnID: Integer; AName: PChar ): Boolean; virtual;
  51.       procedure AppendMRUList( AWnd: HWND ); virtual;
  52.       procedure UpdateMRUList( AWnd: HWND ); virtual;
  53.       procedure LoadMRUList( AWnd: HWND; IniFile, KeyName: PChar ); virtual;
  54.       procedure SaveMRUList( IniFile, KeyName: PChar ); virtual;
  55.     end;
  56.  
  57. implementation
  58. (*
  59. ===============================================================================
  60.   constructor TMRULIst.Init( CWnd: HWND; ALimit, ADelta: Integer );
  61.  
  62.   --> CWnd = Handle to the MDI Client Window if you are using the MDI interface
  63.       ALimit = Maximum number of remembered files allowed in File menu list
  64.       ADelta = Not used, is set to 0 by the Initialization procedure
  65. ===============================================================================
  66.   destructor TMRUList.Done
  67.  
  68.   --> Done = Calls the inherited TCollection disposal method and disposes of
  69.              all the Items in the List. Be sure to call SaveMRUList before
  70.              calling this method.
  71. ===============================================================================
  72.   procedure TMRUList.AddMRUItem( AWnd: HWND; AName: PChar );
  73.  
  74.   --> AWnd = Handle to the Window which owns the Menu
  75.       AName = A null terminated string containing the Filename to add to the
  76.               list. This procedure will handle duplicates.
  77. ===============================================================================
  78.   procedure TMRUList.DeleteMRUItem( AWnd: HWND; AName: PChar );
  79.  
  80.   --> AWnd = Handle to the Window which owns the Menu
  81.       AName = A null terminated string containing the Filename to remove from
  82.               the list.
  83. ===============================================================================
  84.   function TMRUList.GetMRUItem( AnID: Integer; AName: PChar ): Boolean;
  85.  
  86.   --> AnID = The MenuID of one of the Files in the Filelist. This will range
  87.              from 5000 to 5008 depending on how many Files you allow to be
  88.              saved in the list. This unit will handle up to 9 files.
  89.       AName = A null terminated string which is used to pass back the Filename
  90.               chosen from the Filelist. The memory for this string must have
  91.               been allocated before calling this routine or you will have
  92.               a GP fault.
  93. ===============================================================================
  94.   procedure TMRUList.AppendMRUList( AWnd: HWND );
  95.  
  96.   --> This procedure is for use when you change the menu by either SetMenu()
  97.       or through WM_MDISETMENU. It should be called immediately after the call
  98.       to SetMenu() or after posting the WM_MDISETMENU but before calling
  99.       DrawMenuBar().
  100.       AWnd = Handle to the window owning the Menu
  101. ===============================================================================
  102.   procedure TMRUList.UpdateMRUList( AWnd: HWND );
  103.  
  104.   --> AWnd = Handle to the window owning the Menu
  105.       This procedure redraws the Menubar to include any additions or deletions
  106.       to the FileList. It handles adding and removing the Separators needed.
  107. ===============================================================================
  108.   procedure TMRUList.LoadMRUList( AWnd: HWND; IniFile, KeyName: PChar );
  109.  
  110.   --> This procedure will load the saved FileList from a given Ini file using
  111.       a given key. If IniFile and KeyName are blank strings then the procedure
  112.       uses 'WIN.INI' as the IniFile and 'files' as the Keyname.
  113.       AWnd = Handle to the Window owning the Menu
  114.       IniFile = A null terminated string containing the name of the INI file
  115.                 to use. This may be left blank, as '', in which case the
  116.                 Windows win.ini file will be used.
  117.       KeyName = A null terminated string containing the Section name to use
  118.                 when storing or retrieving the list of filenames. This may
  119.                 also be left blank in which case the default name 'files'
  120.                 will be used as the Section name.
  121. ===============================================================================
  122.   procedure TMRUList.SaveMRUList( IniFile, KeyName: PChar );
  123.  
  124.   --> See above for a description of the usage of IniFile and KeyName.
  125.       This procedure will write the remembered filenames into an .ini file
  126.       of your choice and under a Section key also of your choice.
  127. ===============================================================================